$(document).ready(function(){
	//flashsale banner
	$('.flashsale-banner').mouseenter(function(){
		var parent = $(this).parent();
		$('.banner-desc',$(parent)).slideDown();
	}).mouseleave(function() {
		var parent = $(this).parent();
		$('.banner-desc',$(parent)).slideUp();
	});
	
	//flashsale slider
    $('.flashsale-other').jcarousel({
        scroll: 1,
        auto: 5,
        animation: 800,
        wrap: 'last'
    });

});

function flashSalesRegister(){
    var email = $("#flashSalesLetters").val();
    //alert(email);return false;
    if(email == "Địa chỉ email" || email == "")
    {
        alert("Chưa nhập email");
        $("#flashSalesLetters").focus(); // set the focus to this input
        return false;
    }
    if(!email.match(/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/))
    {
        alert("Email không đúng định dạng");
        $(text_input).focus(); // set the focus to this input
        return false;
    }

    $.ajax({
        url: '/naima/frontend/newsLetter/register',
        dataType: 'json',
        data: {
            email: $("#flashSalesLetters").val()
        },
        success: function(result){
            if(result.status){
                alert(result.message);
            } else {
                alert(result.message);
            }
        }
    });
}